package com.gz.moreaseManager.core.modal;

import java.io.Serializable;

public class AjaxResult<E> implements Serializable {

	/**
	 * 状态码
	 */
	protected Integer code;
	/**
	 * 消息信息
	 */
	protected String msg;
	/**
	 * 请求数据
	 */
	protected E data;

	protected AjaxResult() {
	}

	protected AjaxResult(Integer code, String msg, E data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public E getData() {
		return data;
	}

	public void setData(E data) {
		this.data = data;
	}

	public static <E> AjaxResult<E> success() {
		return new AjaxResult<>(HttpCode.SUCCESS.getCode(), null, null);
	}

	public static <E> AjaxResult<E> success(E data) {
		return new AjaxResult<>(HttpCode.SUCCESS.getCode(), null, data);
	}

	public static <E> AjaxResult<E> build(HttpCode code, String msg) {
		return new AjaxResult<>(code.getCode(), msg, null);
	}

	public static <E> AjaxResult<E> build(HttpCode code, String msg, E data) {
		return new AjaxResult<>(code.getCode(), msg, data);
	}
}